package main

import "fmt"

//java翻译版本 https://blog.csdn.net/huangzhilin2015/article/details/88716174  go没有三目表达式？
func fun(a int) int {
	max := 1 << 30
	n := a - 1
	val := 0
	n = n | (n >> 1)
	n = n | (n >> 2)
	n = n | (n >> 4)
	n = n | (n >> 8)
	n = n | (n >> 16)
	if n < 0 {
		val = 1
	} else {
		if n > max {
			val = max
		} else {
			val = n + 1
		}
	}
	return val

}

func main() {

	fmt.Print(fun(9))
	//fmt.Println(2<<3)
}
